<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>
        文章类型添加
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">

    <link rel="stylesheet" href="/static/css/x-admin.css" media="all">
</head>
<body>
<div class="x-body">
    <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">

        <div class="layui-tab-content" >
            <div class="layui-tab-item layui-show">
                <form class="layui-form layui-form-pane" action="">
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>文章类型
                        </label>
                        <div class="layui-input-block">
                            <select name="pid" id="role">
                                <option value="0">--顶级分类--</option>
                                {foreach name="date" id="val"}
                                <option {$name.pid==$val.id?'selected':''} value="{$val.id}">{$val.catename}</option>
                                {/foreach}

                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>类型名称
                        </label>
                        <div class="layui-input-block">
                            <input type="text" name="name" autocomplete="off" placeholder="5个左右,8汉字以内,用英文,隔开"
                                   class="layui-input" lay-verify="required" value="{$name.catename}">
                            <input type="hidden" name="id" value="{$name.id}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">状态</label>
                        <div class="layui-input-block">
                            <input type="radio" name="status" value="0" title="启用" >
                            <div class="layui-unselect layui-form-radio layui-form-radioed"><i class="layui-anim layui-icon layui-anim-scaleSpring"></i>
                                <div>启用</div>
                            </div>
                            <input type="radio" name="status" value="1" title="禁用" >
                            <div class="layui-unselect layui-form-radio"><i class="layui-anim layui-icon"></i>
                                <div>禁用</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <button class="layui-btn" lay-submit="" lay-filter="*">
                            保存
                        </button>
                    </div>
                </form>
                <div style="height:100px;"></div>
            </div>

        </div>
    </div>
</div>
<script src="/static//lib/layui/layui.js" charset="utf-8"></script>
<script src="/static/js/x-layui.js" charset="utf-8"></script>
<script>
    layui.use(['element','layer','form'], function(){
        $ = layui.jquery;//jquery
        lement = layui.element();//面包导航
        layer = layui.layer;//弹出层
        form = layui.form();


        //监听提交
        form.on('submit(*)', function(data){
            var name = $("input[name=name]").val();
            if(name ==""){
                layer.msg("文章分类名称不能为空！",{icon:5,time:2000});return false;
            }
            $data = data.field;
            $.ajax({
                type:"post",
                url:"{:url('do_articletype_update')}",
                data:$data,
                success:function (res) {
                    if(res.status==1000){
                        layer.msg(res.msg,{icon:1,time:1000});
                        setTimeout(function(){
                            window.parent.location.reload();
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        },1000);
                        return false;
                    }else{
                        layer.msg(res.msg,{icon:5,time:2000});return false;
                    }
                }
            });
            return false;
        });

    })
</script>

</body>
</html>